<template>
	<view>

		<view class="content">
			<view class="list">
				<block v-for="(item,index) in addressList" :key="index">
					<view class="row">
						<view class="left">
							<view class="head">
								{{index+1}}
							</view>
						</view>
						
						<view class="center">
							<view class="name-tel">
								<view class="name">{{item.consignee}}</view>
								<view class="tel">{{item.mobile}}</view>
								<view class="default" v-if="item.default_site==1">
									默认
								</view>
							</view>
							<view class="address">
								{{item.region}}{{item.detailed}}
							</view>
						</view>
						
						<view class="right">
							<view class="icon bianji" @tap.stop="edit(item)">
								<image style="width: 60upx; height: 60upx;" :src="addressIcon"></image>
							</view>
						</view>
						
					</view>
				</block>
			</view>
		</view>
		<view class="add">
			<view class="btn" @tap="add">
				<view class="icon"></view>新增地址
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				isSelect: false,
				addressList: [],
				sites: '',
				addressIcon: require('@/static/address/redact.png')
			}
		},
		onShow() {
			this.init()
		},
		onLoad(e) {

		},
		methods: {
			init() {
				this.$http('address.addLst', {
					token: this.$tools.getToken()
				}).then(res => {
					console.log('res', res)
					if (res.code == 200) {
						this.addressList = res.data.data
					}
				})
			},
			edit(row) {
				uni.setStorage({
					key: 'address',
					data: row,
					success() {
						uni.navigateTo({
							url: '/pages/address/edit'
						})

					}
				});

			},
			add() {
				uni.navigateTo({
					url: '/pages/address/add'
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	view {
		display: flex;
	}

	// .icon {
	// 	&.bianji {
	// 		&:before{content:"\e61b";}
	// 	}
	// 	&.tianjia {
	// 		&:before{content:"\e81a";}
	// 	}
	// }
	.add {
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 120upx;
		justify-content: center;
		align-items: center;

		.btn {
			height: 80upx;
			border-radius: 80upx;
			margin: 0 46rpx;
			width: 100%;
			background: linear-gradient(128.5deg, rgba(250, 229, 104, 1) 0%, rgba(255, 200, 47, 1) 100%), linear-gradient(135.25deg, rgba(248, 220, 89, 1) 0%, rgba(246, 188, 87, 1) 100%), rgba(204, 204, 204, 1);
			justify-content: center;
			align-items: center;

			.icon {
				height: 80upx;
				color: #fff;
				font-size: 30upx;
				justify-content: center;
				align-items: center;
			}

			font-size: 30upx;
		}
	}

	.list {
		flex-wrap: wrap;

		.row {
			width: 96%;
			padding: 20upx 2%;

			.left {
				width: 90upx;
				flex-shrink: 0;
				align-items: center;

				.head {
					width: 70upx;
					height: 70upx;
					background: linear-gradient(128.5deg, rgba(250, 229, 104, 1) 0%, rgba(255, 200, 47, 1) 100%), linear-gradient(135.25deg, rgba(248, 220, 89, 1) 0%, rgba(246, 188, 87, 1) 100%), rgba(204, 204, 204, 1);

					justify-content: center;
					align-items: center;
					border-radius: 60upx;
					font-size: 35upx;
				}
			}

			.center {
				width: 100%;
				flex-wrap: wrap;

				.name-tel {
					width: 100%;
					align-items: baseline;

					.name {
						font-size: 34upx;
					}

					.tel {
						margin-left: 30upx;
						font-size: 24upx;
						color: #777;
					}

					.default {

						font-size: 22upx;
						background-color: #ff0000;
						color: #fff;
						padding: 0 18upx;
						border-radius: 24upx;
						margin-left: 20upx;
					}
				}

				.address {
					width: 100%;
					font-size: 24upx;
					align-items: baseline;
					color: #777;
				}
			}

			.right {
				flex-shrink: 0;
				align-items: center;
				margin-left: 20upx;

				.icon {
					justify-content: center;
					align-items: center;
					width: 80upx;
					height: 60upx;
					border-left: solid 1upx #aaa;
					font-size: 40upx;
					color: #777;
				}
			}
		}
	}
</style>
